//@author A0101856J

//The logic class is in charge of most of the data manipulation in Keyboard warrior. It passes
//user inputs to the parser class for processing before carrying out the neccessary operations.
//It also acts as a facade for the task list class, calling the corresponding functions in the 
//task list class for certain operations.

#ifndef _LOGIC_H_
#define _LOGIC_H_

#include <string>
#include <assert.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include "TaskList.h"
#include "Parser.h"
#include "Task.h"
#include "DeadlineTask.h"
#include "FloatingTask.h"
#include "TimedTask.h"
#include "History.h"
#include "constants.h"

class Logic
{

private:
	TaskList taskList;
	static vector<int> searchResultIndices;
	static Task* selectedTask;
public:
	Logic();
	~Logic();

	static void initiate(string &);
	static CommandType executeCommand(string, string&);
	static int addTask(vector<string>, string&);
	static int deleteTask(vector<string>, string&);
	static void displayIndividualTask(Task*,string&);
	static int editTask(Task* task,vector<string>,string&);
	static int editTask(vector<string>, string&);
	static int displaySearchResults(string&);
	static int searchTasks(string);
	static int searchByDesc(string);
	static int searchByDate(Date);
	static int searchByTime(Time);
	static CommandType displayTask(string&);
	static int setTaskDone(string, bool, string&);
	static int saveFile();
	static void loadFile();
	static int getTaskSummary(string&);
	static void displayEditedTask(string desc,Date startDate,Time startTime,Date endDate,Time endTime,bool done,string& results);
	static bool isValidTask(string desc,Date startDate,Time startTime,Date endDate,Time endTime,Task*&);

	static void resetBuffer();
};

#endif